﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace template_dll
{
    public partial class Form4 : Form
    {
        public Form4()
        {
            InitializeComponent();
        }

        public SqlConnection conn;
        public DataTable dt;

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridView1.SelectedRows.Count > 0)
                {
                    SqlStorProc.sp_params[] par = new SqlStorProc.sp_params[1];
                    par[0].name = "@id";
                    for (int i = dataGridView1.SelectedRows.Count - 1; i > -1; i--)
                    {
                        par[0].value = dataGridView1.SelectedRows[i].Cells["ИД строки"].Value;
                        new SqlStorProc().SqlProcExecNonQuery(conn, "pas_Actions_PrizeInfoDel", 30, par);
                        dataGridView1.Rows.RemoveAt(dataGridView1.SelectedRows[i].Index);
                    }
                    MessageBox.Show("Строки удалены");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void Form4_Load(object sender, EventArgs e)
        {
            dataGridView1.DataSource = dt.DefaultView;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            dt = (dataGridView1.DataSource as DataView).ToTable();
        }
    }
}
